package com.itheima.d7_thread_communication;

public class Foodie implements Runnable {
    @Override
    public void run() {
        while (true){
            synchronized (Desk.class){
                if (Desk.flag){
                    System.out.println("吃货吃包子");
                    Desk.flag = false;
                    Desk.class.notify();
                    try {
                        Desk.class.wait();
                    } catch (InterruptedException e) {
                        throw new RuntimeException(e);
                    }
                }else {
                    System.out.println("吃货白跑一趟");
                }
                try {
                    Thread.sleep(100);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
        }
    }
}
